<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ page import="org.edu.system.DBConnect" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.time.*" %>
<%@ page import="java.text.*" %>
<%@ page import="java.util.Calendar" %>
<%
	String tc_id = (String)(session.getAttribute("UserName"));
	String sql = "SELECT * FROM teacher WHERE tc_id = '" + tc_id + "'";
	System.out.println(sql);
	
	Connection con = DBConnect.getCon();
	Statement stmt = null;
	ResultSet rs = null;
	stmt = con.createStatement();
	rs = stmt.executeQuery(sql);//执行命令
	if (rs.next())// 如果记录集非空，表明有匹配的用户ID
	{
			//正常进行
	} else {
		// 否则登录失败
		// response.sendRedirect ( "MyJsp.jsp" );
		response.sendRedirect("login_failure.jsp");
	}
%>
<!DOCTYPE html>
<html>
<head>
<link href="./bootstrap/css/bootstrap.min.css" rel="stylesheet">
<meta charset="utf-8">
<title>教师教务管理系统 - 学生考勤</title>
</head>
<body style="width:900px; margin:0 auto;">
<br>
<table class="table table-striped table-bordered" style="text-align:center">
	<tr>
		<th style="text-align:center">学号</th>
		<th style="text-align:center">姓名</th>
		<th style="text-align:center">状态</th>
	</tr>
<%
	String lesson_id = request.getParameter("lesson_id");
	sql = "select s.stu_id,s.stu_name,a.status from attendance a,student s WHERE a.stu_id = s.stu_id and lesson_id = '"+lesson_id+"'";
	stmt = con.createStatement();
	rs = stmt.executeQuery(sql);//执行命令
	while (rs.next())// 如果记录集非空，表明有匹配的用户ID
	{
		out.print("<tr>");
		out.print("<td>"+rs.getString("stu_id")+"</td>");
		out.print("<td>"+rs.getString("stu_name")+"</td>");
		if(rs.getString("status").equals("2"))
			out.print("<td>未签到</td>");
		if(rs.getString("status").equals("1"))
			out.print("<td>签到</td>");
		out.print("</tr>");
	}
%>
</table>
</body>
</html>